package com.taiyuan.tongcheng.ui;

import org.kymjs.kjframe.ui.BindView;

import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.taiyuan.tongcheng.db.TcDbHelper;
import com.tytc56.user.R;
/**
 * 
* @Description 个人信息layout
* @author wzq
* @date 2015-9-24 下午1:36:32
* @update (date)
* @version V1.0
 */
public class PersonInfoActivity extends BaseActivity {
//widget
	@BindView(id = R.id.rl_name, click = true)
	private RelativeLayout nameLayout;
	@BindView(id = R.id.rl_name, click = true)
	private RelativeLayout telLayout;
	@BindView(id = R.id.tv_user_name)
	private TextView nameTv;
	@BindView(id = R.id.tv_user_tel)
	private TextView telTv;
//intent
	private Intent settingIntent;
	//请求code
	public static final int RES_UPDATA=1;;
	@Override
	public void setRootView() {
		super.setRootView();
		setContentView(R.layout.activity_userinfo);
	}

	@Override
	public void initWidget() {
		super.initWidget();
		initView();
		nameTv.setText(TcDbHelper.getUser(getApplicationContext()).getName());
		telTv.setText(TcDbHelper.getUser(getApplicationContext()).getMobile());
		settingIntent=new Intent(this,SettingInfoActivity.class);
	}

	@Override
	public void initData() {
	}

	@Override
	protected void initView() {
		super.initView();
		topTv.setText("个人资料");
		rightTv.setVisibility(View.GONE);
	}

	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
		switch (v.getId()) {
		
		case R.id.rl_name:
			startActivityForResult(settingIntent, RES_UPDATA);
			break;
		case R.id.rl_tel:
			
			break;

		default:
			break;
		}
	}
	
	@Override
		protected void onActivityResult(int requestCode, int resultCode, Intent data) {
			// TODO Auto-generated method stub
			super.onActivityResult(requestCode, resultCode, data);
			switch (requestCode) {
			case RES_UPDATA:
				if (resultCode == RESULT_OK) {
					String name=data.getStringExtra("name");
					nameTv.setText(name);
				}
				break;
			}
		}
}
